//
//  CYXCZDetail.m
//  CreditAddressBook
//
//  Created by mosu on 2016/11/4.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYXCZDetail.h"
#import "CYUser.h"
#import "CYHttpTool.h"
#import "CYLoginHttpTool.h"
#import "CYJsonInfo.h"
#import "NSObject+MJKeyValue.h"
#import "CYDES3Util.h"
#import "MBProgressHUD+LE.h"
#import "UIAlertView+Block.h"
#import <ZMCreditSDK/ALCreditService.h>
#import "DCPaymentView.h"
@interface CYXCZDetail ()
@property (weak, nonatomic) IBOutlet UITextField *chepaiTF;
@property (weak, nonatomic) IBOutlet UITextField *xczTF;

@end

@implementation CYXCZDetail

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)submitClick:(id)sender {
     if (_chepaiTF.text.length == 0) {
          CYAlertView(@"请输入车牌号");
          return;
          
     }
     if (_xczTF.text.length == 0) {
          CYAlertView(@"请输入行车证号");
          return;
     }
     DCPaymentView *payAlert = [[DCPaymentView alloc]init];
     payAlert.detail = @"请输入交易密码";
     [payAlert show];
     payAlert.completeHandle = ^(NSString *inputPwd) {
          NSString *desstr = [CYDES3Util encrypt:inputPwd];
          CYUser *user = [CYLoginHttpTool userData].user;
          [MBProgressHUD showMessage:nil toView:self.view];
          [CYHttpTool postWithURL:[CYURL shared].saveJuHeCar params:@{@"userId":user.userId,@"token":user.token,@"dealCode":desstr,@"licensePlateNumber":_chepaiTF.text,@"vinCode":_xczTF.text} success:^(id json) {
               [MBProgressHUD hideHUDForView:self.view animated:YES];
               CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
               CYAlertView(jsoninfo.message);
               if (jsoninfo.isSuccess) {
                    //
                    
               }
               
          } failure:^(NSError *error) {
               [MBProgressHUD hideHUDForView:self.view animated:YES];
               CYLog(@"error = %@",error);
               CYAlertView(@"网络错误");
               
          }];
          
          
     };

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
